<?php
class Form_Order extends  Zend_Form
{
	/**
	 * 
	 * @var Model_Product
	 */
	private $_model;
	private $_priceOpts ;

	public function init(){
		
		$this->_model = Model_Product::initModel();
		$this->_priceOpts = Model_Product::getPriceOpts();
		$this->setName("frmOrder");
		$this->setMethod("post");
		$this->setAction("/order/sum");
		
		$orderName = new Zend_Form_Element_Text("orderName");
		$orderName->setOptions(array('autocomplete'=>'off'));
		
		$products = new Zend_Form_Element_MultiCheckbox("products");
		
		foreach($this->_model as $key=>$value){
			//$products->addMultiOption($value->getId(),$value->getName());
			$this->addElement("select","price_".$value->getId());
			$this->getElement("price_".$value->getId())
				->addMultiOptions($this->_priceOpts);
			$this->addElement("text","amount_".$value->getId());
		}
		
		$this->addElement("radio","cSticks",array(
			'multiOptions'=>array('เอามาด้วย','ไม่ต้องเอามา เปลือง มีแล้ว')
		));
		
		$this->addElements(array(
			$products
			,$orderName
			,new Zend_Form_Element_Reset("reset")
			, new Zend_Form_Element_Submit("submit")
			,new Zend_Form_Element_Textarea("address")
		));
		
		$this->setDecorators(array(
			array('ViewScript',
				array('viewScript'=>'index/order-form.phtml')
			),
			'Form'
		));	
	}

}
?>